<template>
  <div class="app-container">
    <el-form v-show="showSearch" ref="queryForm" :model="queryParams" size="small" :inline="true" label-width="90px">
      <el-form-item label="订单号码：" prop="orderNum">
        <el-input v-model="queryParams.orderNum" placeholder="订单号码" clearable style="width: 300px"
          @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="客户姓名：" prop="clientName">
        <el-input v-model="queryParams.clientName" placeholder="客户姓名" clearable style="width: 300px"
          @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="产品名称" prop="productionNames">
        <el-input v-model="queryParams.productionNames" placeholder="产品名称" clearable style="width: 300px"
          @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="逾期天数" prop="overdueDateNum">
        <el-input v-model="queryParams.overdueDateNum" placeholder="逾期天数" clearable style="width: 300px"
          @keyup.enter.native="handleQuery" />
      </el-form-item>
 
      <el-form-item label="申请时间：">
        <el-date-picker v-model="dateRange" style="width: 300px" value-format="yyyy-MM-dd" type="daterange"
          range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" />
      </el-form-item>

      <el-form-item label="逾期状态：" prop="xxxvalue">
      <el-select v-model="queryParams.xxxvalue" placeholder="全部" clearable style="width: 300px">
        <el-option v-for="item in options" :key="item.xxxvalue" :label="item.label" :value="item.xxxvalue">
        </el-option>
      </el-select>
      </el-form-item>

      <el-form-item>
        <div style="margin-right: 50px;">
          <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">查询</el-button>
        </div>
      </el-form-item>
      <el-form-item>
        <div style="margin-right: 50px;">
          <el-button type="primary" icon="el-icon-search" size="mini" @click="handleUpdate">批量催收</el-button>
        </div>
      </el-form-item>
    </el-form>
    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button v-hasPermi="['system:post:export']" type="warning" plain icon="el-icon-download" size="mini"
          @click="handleExport">导出</el-button>
      </el-col>
      <right-toolbar :show-search.sync="showSearch" @queryTable="getList" />
    </el-row>
    <!-- data=你后台查出的数据 -->
    <el-table v-loading="loading" :data="secondtrialList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="40" align="center" />
      <el-table-column label="订单号" align="center" prop="orderNum" />
      <el-table-column label="产品名称" align="center" prop="productionNames" />
      <el-table-column label="客户姓名" align="center" prop="clientName" />
      <el-table-column label="申请金额" align="center" prop="loanAmount" />
      <el-table-column label="逾期状态" align="center" prop="applicantStatus" >
        <template slot-scope="scope">
                    <dict-tag :options="dict.type.loan_info_applicant_status" :value="scope.row.applicantStatus" />
                </template>
      </el-table-column>
      <el-table-column label="逾期天数" align="center" prop="overdueDateNum" />
      <el-table-column label="下单时间" align="center" prop="creditTime" >
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.creditTime) }}</span>
        </template>
      </el-table-column>
      <el-table-column label="资金方" align="center" prop="companyName" />
      <el-table-column label="渠道" align="center" prop="channelName" />
      <el-table-column label="业务经理" align="center" prop="opreatorName" />
      <el-table-column label="负责人" align="center" prop="principalName" />
      
    </el-table>
    <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
      @pagination="getList" />
  </div>
</template>
  
<script>
// 导入api
import { findAll } from '@/api/dlay'
import { updateOverdue } from '@/api/dlay'

export default {
  // 字典导入
  dicts: ['loan_info_applicant_status', 'loan_info_audit_result'],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 复审列表数据
      secondtrialList: [],
      // 弹出层标题
      title: '',
      // 是否显示弹出层
      open: false,
      // 日期范围
      dateRange: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        loanId: '',
        clientName: undefined,
        phone: undefined,
        citizenIdentity: undefined,
        applicantStatus: undefined,
        origin: undefined,
        productionNames: undefined
      },
      // 表单参数
      form: {},
      options: [{
          xxxvalue: 1,
          label: '今日逾期'
        }, {
          xxxvalue: 2,
          label: '昨日逾期'
        }, {
          xxxvalue: 3,
          label: '逾期三天'
        }, {
          xxxvalue: 4,
          label: '逾期0-30天'
        }, {
          xxxvalue: 5,
          label: '逾期30-60天'
        },{
          xxxvalue: 6,
          label: '逾期60-90天'
        },{
          xxxvalue: 7,
          label: '逾期90天以上'
        }],
        xxxvalue: 0
    }
  },
  created() {
    this.getList()
    //this.updateList()
  },
  methods: {
    getList() {
      this.loading = true
      //console.log(this.addDateRange(this.queryParams, this.dateRange))
      //debugger
      findAll(this.addDateRange(this.queryParams, this.dateRange)).then(res => {
        console.log(res);
        //debugger
        let arr = []
        let i = 0
        res.rows.forEach(row => {
          if (row.applicantStatus == 13 ) {
            // console.log(row)
            arr[i++] = row
          }
        });
        // console.log(arr)
        this.secondtrialList = arr
        console.log(this.secondtrialList);
        this.total = arr.length
        this.loading = false
      }).catch()
    },
    updateList(){
      updateOverdue(this.ids).then().catch();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.dateRange = [];
      this.resetForm("queryForm");
      this.handleQuery();
    },
    handleQuery() {
      // console.log('这是点击事件')
      console.log(this.queryParams)
      //debugger
      this.queryParams.pageNum = 1
      this.getList()
    },
    handleUpdate() {
      // console.log('这是点击事件')
      //console.log(this.queryParams)
      //debugger
      this.queryParams.pageNum = 1
      this.updateList()
    },
    reset() {
      this.form = {
        code: 1,
        status: '0'
      }
      this.resetForm('form')
    },
    handleExport() {
      this.download('overdueManagement/export', {
        ...this.queryParams
      }, `逾期订单信息_${new Date().getTime()}.xlsx`)
    },
    //多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.loanId)
      
      this.single = selection.length !== 1
      this.multiple = !selection.length
    }
  },
  submitForm() {
    console.log('hhhhhhh')
  }

}

</script>
  
  